<!DOCTYPE html>
<html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="language" content="en" />

        <!-- blueprint CSS framework -->
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/screen.css" media="screen, projection" />
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/print.css" media="print" />

        <!--[if lt IE 8]>
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/ie.css" media="screen, projection" />
        <![endif]-->

        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/main.css" />
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/form.css" />
        <?php echo CHtml::scriptFile('/js/jquery-1.10.2.min.js'); ?>
        <?php //echo CHtml::scriptFile('/js/angular.js'); ?>
        <?php Yii::app()->bootstrap->register(); ?>
        <title><?php echo CHtml::encode($this->pageTitle); ?></title>
        <script src="/js/html2canvas.min.js"></script>
    </head>
    <body>
        <div class="container" id="page">
            <div id="header">
                <div id="logo">
                    <div class="shareweb_logo"><a title="<?php echo CHtml::encode(Yii::app()->name); ?>"></a></div>
                    <button type="button" class="btn btn-primary" id="createImg">Create</button>
                    <button type="button" class="btn btn-danger" id="saveImg">Save</button>
                </div>
            </div><!-- header -->
            <div id="mainmenu">
                <?php
                $this->widget('zii.widgets.CMenu', array(
                    'items' => array(
                        array('label' => 'Home', 'url' => array('/site/index')),
                        array('label' => 'User', 'url' => array('/user/index')),
                        array('label' => 'Album', 'url' => array('/album/index')),
                        array('label' => 'Picture', 'url' => array('/picture/index')),
                        array('label' => 'Contact', 'url' => array('/site/contact')),
                        array('label' => 'Weather', 'url' => array('/site/weather')),
                        array('label' => 'Angular', 'url' => array('/ng/index')),
                        array('label' => 'Login', 'url' => array('/site/login'), 'visible' => Yii::app()->user->isGuest),
                        array('label' => 'Logout (' . Yii::app()->user->name . ')', 'url' => array('/site/logout'), 'visible' => !Yii::app()->user->isGuest)
                    ),
                    'htmlOptions' => array(),
                ));
                ?>
            </div><!-- mainmenu -->
            <?php if (isset($this->breadcrumbs)): ?>
                <?php
                $this->widget('zii.widgets.CBreadcrumbs', array(
                    'links' => $this->breadcrumbs,
                ));
                ?><!-- breadcrumbs -->
            <?php endif ?>

            <?php echo $content; ?>
            <div class="clear"></div>
            <div id="footer">
                <?php echo Yii::powered(); ?>
            </div>
        </div>
        <script>
            $(document).ready(function() {
                $("#createImg").click(function() {
                    $("canvas").remove("canvas");
                    html2canvas(document.body, {
                        onrendered: function(canvas) {
                            $("body").append(canvas);
                            $("#page").attr("src", canvas.toDataURL());
                        }
                    });
                });

                $("#saveImg").click(function() {
                    $.ajax({
                        type: "POST",
                        url: "/canvas/upload",
                        data: {image: $("#page").attr("src")},
                        success: function(msg) {
                            alert("Data Saved: " + msg);
                        }
                    });
                });
            });
        </script>
    </body>
</html>